home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.92 / crossfir / crossfire-0.92.5 / doc / skills_developer.doc < prev    next >
Text File  |  1996-07-24  |  15KB  |  430 lines

  1.  
  2.  
  3.     SKILLS/EXPERIENCE DOCUMENTATION for DEVELOPERS
  4.     ----------------------------------------------
  5.  
  6.     - Summary -
  7.  
  8.     0. Introduction 
  9.  
  10.     1. Sketch of system
  11.        a. Initialization - how skills and experience are linked 
  12.  
  13.     2. How to adjust skill parameters/links with experience objects
  14.        a. legal values for experience category
  15.        b. legal values for associated stats 
  16.  
  17.     3. How to add new skills
  18.        a. creation of new skill: outline of needed steps
  19.            b. important skills archetype values
  20.        
  21.         4. How to reconfigure the experience categories 
  22.  
  23.     5. Appendices
  24.        a. glossary of terminology
  25.        b. road map of likely routine calls in exp/skills code
  26.        c. Known Bugs/Todo list
  27.  
  28.  
  29.  
  30.     0. Introduction
  31.     ---------------
  32.  
  33.     When crossfire is compiled with the ALLOW_SKILLS flag defined 
  34.     the new skills/experience system is enabled. This system is coded 
  35.     with flexibility in mind so that the user may reconfigure the 
  36.     skills/exp code as they desire in a fairly easy way.  In this 
  37.     document, a discussion of issues of interest to developers is 
  38.     presented.
  39.  
  40.     Corrections or comments on how to improve this document are 
  41.     welcome. 
  42.             
  43.                 -b.t. (thomas@astro.psu.edu) 
  44.                 8/30/95
  45.  
  46.  
  47.  
  48.     1. Sketch of system
  49.     -------------------
  50.  
  51.     In the skills/experience code, players gain experience for the 
  52.     activities which they perform in the game ("You are what you do"). 
  53.     The activities a player may engage in are controlled by the skills 
  54.     they possess. All players start with a basic set of skills which 
  55.     they may expand through adventuring. While monsters do not gain
  56.     experience from the use of skills, they may use any skills 
  57.     which exist in their inventory if they have the can_use_skill 
  58.     flag set.
  59.  
  60.     In the code, both experience and skills are objects which exist 
  61.     in the player/monster inventory. Both NPC/monsters and players
  62.     use the same skill archetypes. Not all skills are however enabled
  63.     for monster use. Check the Skills_players.doc for available 
  64.     NPC skills. 
  65.  
  66.  
  67.        a. Initialization - how skills and experience are linked 
  68.  
  69.     During initialization, the code binds skills and experience 
  70.     objects according to their shared stats (see link_skills_to_exp() 
  71.     in skill_util.c). The skills[] array (in skillist.h) is used by 
  72.     the code to initialize the default parameters of the skills 
  73.     objects. After initialization, the code realigns the bindings and 
  74.     skill parameters according to any entries in the skill_params file 
  75.     (see below, and read_skill_param() in skill_util.c). If no skill 
  76.     is entered in the skill_params file, the default binding is used. 
  77.  
  78.  
  79.  
  80.     2. How to adjust skill parameters/links with experience objects
  81.     ---------------------------------------------------------------
  82.  
  83.     Alteration of the skill_params file (in the lib directory) will 
  84.     change the default skills parameters (without recompiling the 
  85.     game). Each entry has the following format (for example):
  86.  
  87.     <skill name>
  88.     int int  int float  int int int
  89.  
  90.     An example entry:
  91.  
  92.     set traps
  93.     2 5   3 2.0   5 1 99
  94.  
  95.     Skill name is *not* changeable by the skill_params file, in fact
  96.     it appears in the file only to identify the skill for which 
  97.     the skill_params file will alter the parameters.  In order, the 
  98.     parameters which are changeable are the numerical values below
  99.     the skill name:
  100.  
  101.     -associated experience category, see below for value (int)  
  102.     -time to use the skill, in ticks (int)
  103.     -base experience to award for successful use (int) 
  104.     -level experience modifier (see calc_skill_exp()) (float)    
  105.     -primary stat of skill, see below (int) 
  106.     -secondary stat of skill, see below (int) 
  107.     -tertiary stat of skill, see below (int) 
  108.     
  109.  
  110.        a. legal values for experience category 
  111.  
  112.     Numerical values of the experience categories is shown by using 
  113.     the 'crossfire -m5' command. Release code has "7" experience 
  114.     objects. A dump of the release code shows:
  115.  
  116.   exper_catgry      str      dex      con      wis      cha      int      pow 
  117.   0-agility      0      1      0      0      0      0      0 
  118.   1-personality  0      0      0      0      1      0      0 
  119.   2-mental      0      0      0      0      0      1      0 
  120.   3-physique      1      0      1      0      0      0      0 
  121.   4-magic      0      0      0      0      0      0      1 
  122.   5-wisdom      0      0      0      1      0      0      0 
  123.  
  124.     For example, the value for the "agility" experience object is 
  125.     '0'. The seventh experience category (not listed) is the "none" 
  126.     category.  It always has the value of the last listed experience 
  127.     category plus one (in the above case, the "none" experience 
  128.     category is value '6'). In the skill_params file, setting the 
  129.     experience category to the value for the "none" experience object 
  130.     will make that skill a miscellaneous skill. 
  131.  
  132.  
  133.        b. legal values for associated stats 
  134.  
  135.     The associated stats of a skill may be altered by inputing the
  136.     value of the new stat (as given in living.h) : 
  137.  
  138.      #define STR 0
  139.      #define DEX 1
  140.      #define CON 2
  141.      #define WIS 3
  142.      #define CHA 4
  143.      #define INT 5
  144.      #define POW 6
  145.      #define NO_STAT 99    
  146.  
  147.     In the above example (set traps), the associated skills are set
  148.     to:
  149.  
  150.     -primary stat => Intelligence
  151.     -secondary stat => Dexterity 
  152.     -tertiary stat => no stat
  153.  
  154.  
  155.  
  156.     3. How to add new skills
  157.     -------------------------
  158.  
  159.     Adding a new skill to CF is not overly difficult, it is little 
  160.     more difficult than adding new archetypes and a spell to the game. 
  161.  
  162.  
  163.            a. creation of new skill: outline of needed steps
  164.  
  165.     A number of steps are required to create a new skill. Below I 
  166.     outline the steps need to add a learned skill to the game. Note 
  167.     that in order to add a new skill you will need to acquire the 
  168.     appropriate CF archetype tarfile (crossfire-0.??.?.arch.tar.gz).  
  169.  
  170.     1) Edit a new skills archetype. See below for appropriate para-
  171.        meters.  If you desire the skill to be a skill tool, edit a 
  172.        "face" for the new skill. If you want to have the skill to be 
  173.        learned via a skill scroll, edit a skillscroll for the skill. 
  174.        Place the new archetype(s) in the lib/arch/skills directory. 
  175.        Remember to name your new skill appropriately (ie skill_<new 
  176.        skill name>). 
  177.  
  178.     2) Edit include files. Add a table entry for the skill in 
  179.        skillist.h. Add an index entry for the skill to skills.h. Bump 
  180.        up the value of NROFSKILLS in define.h by one.
  181.  
  182.     3) Edit skill_util.c. Add an entry for the skill in do_skill() (so 
  183.        that it may be used as a "long-range attack"). If the new skill 
  184.        is a hth attack take a look at the attack_hth_skills[] table in 
  185.        do_skill_attack() -- where does the hth attack rank? The most 
  186.        useful attacks should occur earlier in the table. 
  187.  
  188.     4) Create the skill code. If you created a hth attack, you probably 
  189.        can get away with just using attack_hth. For other skills, put
  190.        the skill code in skills.c. If your new skill is to be an 
  191.        "associated" skill, then make sure that it returns the value of 
  192.        calc_skill_exp(). 
  193.  
  194.     5) Edit treasures/artifacts file as needed (esp. if your skill will
  195.        become one of the starting skills, or will show up in shops.) 
  196.  
  197.  
  198.            b. important skills archetype values
  199.  
  200.         Several parameters must be present/set correctly in the skill 
  201.     archetypes or the new skill will not function properly. 
  202.  
  203.     All skills must have: 
  204.       - "type" set to the value of SKILL in define.h  
  205.       - value of "sp" must equal table entry in skills.h
  206.  
  207.     Learned skills must have:
  208.       - "invisible" and "no_drop" set to "1"
  209.  
  210.     Skill tools must have:
  211.       - "face" set to archetype that displays the face. 
  212.       - "weight" and "value" set to reasonable values.
  213.  
  214.     Skill scrolls must have:
  215.       - "type" set to value of SKILLSCROLL in define.h
  216.       - "identified", "material", "nrof" set to "1" 
  217.       - "weight" and "value" set to reasonable values.
  218.        - "slaying" value set to the *archetype* name of the skill that 
  219.         will be learned from reading the scroll.
  220.  
  221.     Skills that will do damage (ie hth attacks) require:
  222.       - value of "dam" and "last_sp" set reasonably.
  223.  
  224.     There are in addition a number of other parameters that may be set
  225.     in skills (and have effect in the game). Take a look at 
  226.     fix_player() in common/living.c and skill archs for more info.
  227.  
  228.  
  229.  
  230.         4. How to reconfigure the experience categories 
  231.     -----------------------------------------------
  232.  
  233.     The experience system is fairly flexible in the number of allowed
  234.     kinds of experience. As each type of experience requires at least
  235.     1 unique stat, the maximum number of experience objects is 8 (incl.
  236.     the "none" category). Because the code in fix_player() currently 
  237.     requires that the "cleric experience object" (used for advancing
  238.     grace) and the "wizard experience object" (use of advancing the 
  239.     amount of mana) are required to be different, the minimum number of 
  240.     experience objects is 3 (incl. the "none" experience object).
  241.     Release skill/exp code has 7 experience objects enabled: physique
  242.     (STR,CON), mental (INT), magic (POW), agility (DEX), wisdom (WIS),
  243.     personality (CHA), and none (NULL). 
  244.  
  245.     To reconfigure the experience system, all that is needed is to edit
  246.     the stat values of the experience archetypes in lib/arch/skills. 
  247.  
  248.     There are a couple of things that should be watched out for when 
  249.     reconfiguring:
  250.  
  251.         1- you will need to set once each of the stats in the 
  252.         experience objects. (ex Cha 1 must occur in one of the exp 
  253.         archetypes). 
  254.  
  255.         2- No 2 experience archs may both have the same stat set. 
  256.         (ex. "Str 1" set in two or more exp. archs is bad news)
  257.  
  258.         3- "Pow 1" and "Wis 1" must occur in different experience 
  259.         archetypes. (Remember the requirement that wiz and cleric
  260.         experience objects have to be different).
  261.  
  262.  
  263.     Compile the new archs, and install the new fonts. Take a look at your
  264.     new alignment by using the 'crossfire -m5' command. Make sure all
  265.     associated skills have an experience category.(!)
  266.  
  267.  
  268.  
  269.     5. Appendices
  270.     -------------
  271.  
  272.  
  273.        a. glossary of terminology
  274.  
  275.         associated skill  -- This is the term for a skill which can 
  276.                      generate experience when used. 
  277.                      Associated skills are linked (or 
  278.                      'associated') with one kind of 
  279.                      experience category.
  280.  
  281.         associated stat      -- this is one of the stats associated with
  282.                      a particular skill (see skills[] array). 
  283.                      The code uses these during initialization 
  284.                            to determine the default bindings of 
  285.                      skills to experience categories, and 
  286.                      during play to know which player stats 
  287.                      will alter the experience gained by using 
  288.                      a particular skill.
  289.  
  290.         experience category  This is one type of experience that it is 
  291.                      possible for players to accumulate in the
  292.                      game. 
  293.  
  294.         experience object -- This is an invisible object. Each 
  295.                      experience object represents a different 
  296.                      "experience category".  Experience of a 
  297.                      player in a particular experience 
  298.                      category is recorded in a unique 
  299.                      experience object which the player has 
  300.                      in their inventory.
  301.     
  302.         learned skill      -- This is a skill which is represented by 
  303.                      an invisible skill object in the player 
  304.                      inventory.
  305.  
  306.         miscellaneous skill  This skill does not generate experience 
  307.                      when it is used. Skill objects which 
  308.                      represent miscellaneous skills are un-
  309.                      linked (not 'associated') to any
  310.                      experience category. 
  311.  
  312.         skill object      -- This may be either an invisible or 
  313.                      visible object carried in the player or
  314.                      monster inventory. If the skill object is 
  315.                      visible is is called a "tool" or "skill 
  316.                      tool". If the skill object is invisible 
  317.                      it is called a "learned skill". Players 
  318.                      may pickup/drop skill tools. Each skill 
  319.                      object represents a unique skill.  Each 
  320.                      skill object in the player inventory 
  321.                      which represents an "associated skill" 
  322.                      is linked to a unique experience object 
  323.                      in the player inventory. Skill objects 
  324.                      which represent "miscellaneous" skills 
  325.                      remain unlinked to any experience 
  326.                      object.
  327.  
  328.         skill tool      -- This is a skill which is represented by 
  329.                      a visible object in the player 
  330.                      inventory. This object may be picked up
  331.                      or dropped by the player.    
  332.  
  333.  
  334.        b. road map of likely routine calls in exp/skills code
  335.  
  336.     In "road maps", horizontal branches are called first, then vertical.
  337.     Note that not all routines may always be called (nor are all 
  338.     functions shown).
  339.  
  340.     Player using a readied skill 
  341.     ----------------------------
  342.     fire() -> check_skill_to_fire() -> change_skill() -> chan_abil() 
  343.        |
  344.        v
  345.      do_skill() -> "skill fctn" -> calc_skill_exp() -> stat_mod_exp() 
  346.         |                         
  347.           v                         
  348.     add_exp()
  349.           
  350.     Player changing skill via "use_skill" command 
  351.     ---------------------------------------------
  352.     change_skill() -> chan_abil() 
  353.  
  354.     Player using a magic item (rod, wand, horn)
  355.     -------------------------------------------
  356.     
  357.     fire() -> check_skill_to_fire() -> change_skill()
  358.        |
  359.        v
  360.     cast_spell()
  361.     
  362.     Player running into a creature (and makes attack)
  363.     -------------------------------------------------
  364.  
  365.     move_player_attack() 
  366.         |
  367.         v
  368.     skill_attack() -> do_skill_attack() -> hth_damage() 
  369.                  |
  370.                  v
  371.                 attack_ob() -> add_exp() 
  372.  
  373.     Player applies a skill tool
  374.     ---------------------------
  375.  
  376.     apply() -> change_skill() -> chan_abil()
  377.  
  378.     Player readies an item that requires a skill to use (melee weapon,
  379.     missile weapon, wand, rod, horn)
  380.     -----------------------------------------------------------------
  381.  
  382.     apply() or apply_special() -> check_skill_to_apply()
  383.         |
  384.         v
  385.        change_skill() -> chan_abil()
  386.  
  387.  
  388.  
  389.        c. Known Bugs/Todo list (some of which concerned w/ 2 magic
  390.     system) 
  391.  
  392.     A minor unusual bugs I know about:
  393.  
  394.     - kills made by summoned pet monsters send experience to the 
  395.     player's correct experience object (and modified correctly
  396.     because set_owner() is now working right). BUT-If a summoned monster
  397.     should ever pickup a skill tool, and apply it, then exp from 
  398.     that monster will no longer go to the player. I suppose I could
  399.     fix this by preventing all "owned" creatures from using skill
  400.     tools.
  401.  
  402.     - if a skill name is misspelled in skill_params file the program 
  403.     will fail to load (heh, crash that is :). This should have been 
  404.     taken care of in lookup_skill_by_name() but it apparently isnt. 
  405.  
  406.  
  407.     Several things might make the exp/skills code better.
  408.  
  409.     == add a spell patch for the cause wounds spells (right now its
  410.        PATH_NULL).
  411.  
  412.     == creation of a "throwing skill" - allow players and NPC's to use
  413.  
  414.     == creation of a "set traps skill" - this would allow players to 
  415.        "create" traps anywhere as long as they have the skill and traps
  416.        components (new archs) which should be able to acquire from 
  417.        disarming traps and find in "specialty" shops for sale.
  418.  
  419.     == more priest spells (that kill stuff, gain priest exp).
  420.  
  421.     == creation of a invisible "skills container" for player skills.
  422.        currently the code just whips through the entire non-container
  423.        inventory of the player to search for skills (cf change_skill()
  424.        routine in skill_util.c). This seems to be kinda inefficient when
  425.        a player is carrying around massive amounts of crap.
  426.  
  427.     == Add exotic weapons attacks in attack_melee_weapon(). For example,
  428.        a 'disarming' attack for player using Sai.
  429.     
  430.